<?php
include('../../__global.php');
include(SERVER_ROOT_PATH.'/include/config/ml_catelog.php');

class aj_scroll_atme extends ml_controller
{
    private $page;
    private $blocknum;
    public function initParam()
    {
        $this->page = (int)$this->input('page','G') - 1;
        $this->blocknum = $this->page * 3 + $this->input('segment','G')-1;
    }
    public function checkParam()
    {
        $this->check_referer();
        if(!$this->check_permission(ML_PERMISSION_LOGIN_ONLY)) {
            return $this->api_output(ML_RCODE_NOLOGIN);
        }
        else if(!$this->check_permission(ML_PERMISSION_LOGIN_CANWRITE)) {
            return $this->api_output(ML_RCODE_NOACTIVE);
        }
    }
    public function main()
    {
        $oAtme = new ml_biz_feed_atMe();
        $rs = $oAtme->main($this->__visitor['uid'] , $this->blocknum);
        if(!$rs)
            $this->api_output(ML_RCODE_BUSY);
        $html = $oAtme->get_html();
        $total = $oAtme->get_total();
        $total_blocks = ceil($total / ml_biz_atmeOutput::PAGESIZE );
        
        $aOutput = array(
            'items' => $html,
            'lastSegment' => $this->blocknum == $total_blocks ? true : false
        );
        $this->api_output(ML_RCODE_SUCC , $aOutput);
    }
    
}
new aj_scroll_atme();